﻿<%@ WebHandler Language="C#" Class="Publish" %>

using System;
using System.Web;
using Whir.Publish;
using Whir.Common.WebHelper;

public class Publish : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        bool bResponse = true;
        RoleHelper.IsLogin();    //登录判断

        //获取参数
        string columnIDs = NetRequest.GetString("columnID");      //栏目ID 以,分隔        
        string BeginDate = NetRequest.GetString("bDate");         //开始日期
        string EndDate = NetRequest.GetString("eDate");           //结束日期
        int newNum = NetRequest.GetInt("newNum", 0);              //最新记录数
        bool IsPublish = true;
        bResponse = (NetRequest.GetInt("type", 1) == 1) ? true : false;   //是否输出js

        try
        {
            publish(columnIDs, BeginDate, EndDate, newNum, IsPublish);
        }
        catch
        { }
    }

    public bool publish(string columnIDs, string bDate, string eDate, int num, bool isPublish)
    {
        System.Web.UI.Page Page = new System.Web.UI.Page();
        if (columnIDs == string.Empty) return false;

        bool result = true;
        Whir.BLL.Whir_Column bll = new Whir.BLL.Whir_Column();
        Whir.Model.Whir_Column[] model = null;

        //获取栏目数据
        if (columnIDs != "-1")
        {
            model = bll.GetModelList(10000, 1, "columnID in (" + columnIDs + ")");
        }
        else
        {
            //值为-1时生成全部栏目
            model = bll.GetModelList(10000, 1, "");
        }

        string[] strResult = new string[2];
        if (model != null)
        {
            try
            {
                CreateHtml index = null;
                bool btn = true;
                foreach (Whir.Model.Whir_Column column in model)
                {
                    //生成栏目首页
                    index = new CreateHtml(column, Page);
                    index.beginDate = bDate;
                    index.endDate = eDate;

                    strResult = index.Bind();//一次性生成
                    btn = bool.Parse(strResult[0]);
                }
            }
            catch
            { }
        }
        return result;
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}